package com.abou.mvc.format;

import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.support.RequestContext;

/**
 * The type formatter
 * 
 * @author ztrt8431
 */
public interface ITypeFormatter {
  
  /**
   * Returns hether the passed object can be formatted by this formatter.
   * 
   * @param value An object
   * @return Whether the passed object can be formatted by this formatter.
   */
  boolean supports(Object value);
  
  /**
   * Returns whether the passed value should be considered as null or empty for
   * this formatter type.
   * 
   * @param value A value.
   * @return Whether the value is empty
   */
  boolean isEmpty(Object value);
  
  /**
   * Formats the passed value according to the passed locale and context.
   * 
   * @param value The value to format
   * @param locale The locale
   * @param request The HTTP request
   * @param requestContext The request context
   * @param textOnly Whether the formatter string should be only a simple text
   *          (no HTML or image).
   * @return The string representation of the passed value or null if this
   *         formatter does not support the passed value type.
   */
  String format(Object value, Locale locale, HttpServletRequest request,
      RequestContext requestContext, boolean textOnly);
}
